﻿using H2.NET.Web.Pages.SMD.Service;
using H2.NET.Web.Workflow.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace H2.NET.Web.Pages.SMD
{
    public partial class uc_store_basic : TaskControl
    {
        public int basic_storeid
        {
            get
            {
                return ViewState["basic_storeid"] == null ? 0 : (int)ViewState["basic_storeid"];
            }
            set
            {
                ViewState["basic_storeid"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            var store = StoreService.GetSmdStoreById(basic_storeid);

            if (store != null && store.StoreID > 0)
            {
                l_authid_new.Text = store.AuthID;
                l_storeStatus.Text = store.StoreStatus;
                l_store_type.Text = store.StoreType;
                l_channel.Text = store.Channel;
                l_region.Text = store.Region;
                l_province.Text = store.Province;
                l_cityName.Text = store.CityName;
                l_MallShortName.Text = store.MallShortName;
                l_MallName.Text = store.MallName;
                l_HouseNumber.Text = store.HouseNumber;
                l_store_name.Text = store.StoreName;
                l_ShopSeq.Text = store.ShopSeq;
                l_ContractPerson.Text = store.ContactPerson;
                l_Telephone.Text = store.PhoneNumber;
                l_address.Text = store.StoreAddress;

                if (store.DealerID != null)
                {
                    var dealer = DealerService.GetById(store.DealerID.Value);

                    dealer_dealerCode_label.Text = dealer.DealerCode;
                    dealer_name_label.Text = dealer.Name;
                    dealer_region_label.Text = dealer.Region;
                    dealer_province_label.Text = dealer.Province;
                    dealer_cityName_label.Text = dealer.CityName;
                }
            }
        }
    }
}